<template>
    <div id="app" v-loading="loading">
        <div class="title"><a class="backPage iconfont icon-icon-test" @click="$router.back(-1)"></a>项目详情</div>
        <el-form class="form" label-position="top">
            <!--div class="title titles">基本信息</div-->
            <el-row :gutter="30">
                <el-col :span="4">
                    <div class="grid-content bg-purple">
                        <el-form-item label="项目名称">
                            <el-input
                                v-model="projectList.name"
                            ></el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="4">
                    <div class="grid-content bg-purple">
                        <el-form-item label="接任务弹窗">
                            <el-input
                                v-model="projectList.accept_tip"
                            ></el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="4">
                    <div class="grid-content bg-purple">
                        <el-form-item label="发任务弹窗">
                            <el-input
                                v-model="projectList.publish_tip"
                            ></el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="4">
                    <div class="grid-content bg-purple">
                        <el-form-item label="最低发布数量">
                            <el-input
                                v-model="projectList.min_total_accept"
                            ></el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="4">
                    <div class="grid-content bg-purple">
                        <el-form-item label="最低单价">
                            <el-input
                                v-model="projectList.min_amount"
                            ></el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="4">
                    <div class="grid-content bg-purple">
                        <el-form-item label="最高允许步骤">
                            <el-input
                                v-model="projectList.max_total_step"
                            ></el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="4">
                    <div class="grid-content bg-purple">
                        <el-form-item label="单步骤最高图频">
                            <el-input
                                v-model="projectList.max_files"
                            ></el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="4">
                    <div class="grid-content bg-purple">
                        <el-form-item label="排序">
                            <el-input
                                v-model="projectList.sort"
                            ></el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="4">
                    <div class="grid-content bg-purple">
                        <el-form-item label="系统模板">
                            <el-select  filterable class="filter"
                                v-model="projectList.template_id"
                            >
                                <el-option label="不选择模板" :value="0"></el-option>
                                <el-option v-for="item in projectList.template"
                                    :key="item.id" :label="item.name" :value="item.id">
                                </el-option>
                            </el-select>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="4">
                    <div class="grid-content bg-purple">
                        <el-form-item label="最低x等级接单"
                        >
                            <el-select   v-model="projectList.min_user_level" placeholder="请选择" class="filter">
                                <el-option value="1"></el-option>
                                <el-option value="2"></el-option>
                                <el-option value="3"></el-option>
                                <el-option value="4"></el-option>
                                <el-option value="5"></el-option>
                                <el-option value="6"></el-option>
                            </el-select>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="4">
                    <div class="grid-content bg-purple">
                        <el-form-item label="别名">
                            <el-select placeholder="请选择" class="filter" v-model="projectList.alias_id">
                              <el-option :value="0" label="不选择"></el-option>
                              <el-option :value="item.id" v-for="(item,index) in alias" :key="index" :label="item.name"></el-option>
                            </el-select>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="4">
                    <div class="grid-content bg-purple">
                        <el-form-item label="项目状态">
                            <el-switch v-model="projectList.status"></el-switch>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="4">
                    <div class="grid-content bg-purple">
                        <el-form-item label="自动通过审批">
                            <el-switch v-model="projectList.auto_pass"></el-switch>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="4">
                    <div class="grid-content bg-purple">
                        <el-form-item label="允许输入任务标题">
                            <el-switch v-model="projectList.is_allow_custom_title"></el-switch>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="4">
                    <div class="grid-content bg-purple">
                        <el-form-item label="图标">
                            <el-upload :show-file-list="false" class="elupload"
                                :headers="{authorizedkey:authorized_key}"
                                :action="host + '/api/console/system/upload'"
                                :on-success="handleUploadSuccess"
                                :data="{
                                        ProjectIcon: projectList.id,
                                        bid: bid
                                }"
                            >
                                <img :src="uploadImgShow(projectList.icon)" class="head" />
                            </el-upload>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="4">
                    <div class="grid-content bg-purple">
                        <el-form-item label="限制用户接单（制度）">
                            <div class="disbox">
                                <el-radio-group
                                    v-model="projectList.timing_type"
                                >
                                    <el-radio :label="1" >24小时</el-radio>
                                    <el-radio :label="0"  style="margin-top:10px;">次日</el-radio>
                                </el-radio-group>
                            </div>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="4">
                    <div class="grid-content bg-purple">
                        <el-form-item label="限制用户接单（x天）">
                            <el-input-number controls-position="right" class="filter"
                                v-model="projectList.timing_period"
                            >
                            </el-input-number>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="4">
                    <div class="grid-content bg-purple">
                        <el-form-item label="限制用户接单（x次）">
                            <el-input-number controls-position="right" class="filter"
                                v-model="projectList.timing_max_accepts"
                            >
                            </el-input-number>
                        </el-form-item>
                    </div>
                </el-col>
            </el-row>
            <el-row :gutter="30">
              <el-col :span="4">
                  <div class="grid-content bg-purple">
                      <el-form-item label="项目ID">
                          {{
                              projectList.id || '-'
                          }}
                      </el-form-item>
                  </div>
              </el-col>
              <el-col :span="4">
                  <div class="grid-content bg-purple">
                      <el-form-item label="上架时间">
                          {{
                              projectList.time_created ?
                              countTrialDate(projectList.time_created * 1000) :
                              '-'
                          }}
                      </el-form-item>
                  </div>
              </el-col>
            </el-row>
            <el-button type="primary" style="margin-top:15px;"
                @click="onSubmit"
            >立即保存</el-button>
        </el-form>
    </div>
</template>

<script>
    import ProjectDetail from './index.js';
    export default ProjectDetail;
</script>
<style lang="scss" scoped>
    .form{
        margin-top:45px;
    }
    .titles{
        margin-top:25px;
        margin-bottom:12px;
        font-size:19px;
    }
    .filter{
        width:100%;
    }
    .elupload{
        .head{
            display:block;
            width:40px;
            height:40px;
            border-radius:4px;
        }
    }
    .userAccept{
        margin-left:10px;
        .elinput{
            width:25%;
            margin:0px 15px;
        }
    }
</style>
